var Device = require('../../NGCore/Client/Device').Device;
var Core = require('../../NGCore/Client/Core').Core;

exports.InterfaceListener = Core.MessageListener.subclass({
    classname: 'InterfaceListener',
    
    initialize: function() {
		Device.OrientationEmitter.addListener(this, this.onUpdate);
	},
	onUpdate : function(msg) { //Orientation Update
		if (msg.type == Device.OrientationEmitter.OrientationType.Interface && msg.orientation != Device.OrientationEmitter.Orientation.Portrait) {
			Device.OrientationEmitter.setInterfaceOrientation(Device.OrientationEmitter.Orientation.Portrait, false);
		}
	},
	destroy: function() {
		Device.OrientationEmitter.removeListener(this);
	},
});